#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <BEntry>
#include <BIcon>
#include <BImage>
#include <BButton>
#include <BFileDialog>
#include <BLineEdit>
#include <BListWidget>
#include <BTabWidget>
#include <BMenuBar>
#include <BMenu>
#include <BMainWindow>
#include "CheckDialog.h"
#include "PropertyBox.h"

using namespace BWE;

class HeadInfo : public BThing
{
public:
	BEntryHolder	headEntry;
	BEntryHolder	htmlEntry;
};

class MainWindow : public BMainWindow
{
public:
	MainWindow();
	~MainWindow();

protected:
	void slotOpenDocument();
	void slotSaveDocument();
	void slotSaveAllDocument();

	void slotHeadPathEditDoubleClicked();
	void slotHtmlPathEditDoubleClicked();
	void slotHeadItemRightClicked(BObject* object, const BValue& value);
	void slotHeadItemDoubleClicked(BObject* object, const BValue& value);

	void slotTabCurrentChanged(BObject* object, const BValue& value);
	void slotTabClicked(BObject* object, BValue& value);
	void slotTabRightClicked(BObject* object, BValue& value);

	void slotTabClosing(BObject* object, BValue& value);
	void slotReadOnlyClicked(BObject* object, const BValue& value);
	void slotRemoveButtonClicked(BObject* object, const BValue& value);

	void slotListMenuTrigger(BObject* object, const BValue& value);
	void slotPageMenuTrigger(BObject* object, const BValue& value);
	void slotTableMenuTrigger(BObject* object, const BValue& value);
	void slotTabMenuTrigger(BObject* object, const BValue& value);

	void slotHtmlItemClicked(BObject* object, const BValue& value);
	void slotHtmlItemRightClicked(BObject* object, const BValue& value);
	void slotHtmlItemChanged(BObject* object, const BValue& value);

	void slotMenuAddTrigger(BObject* object, const BValue& value);
	void slotMenuPrependTrigger(BObject* object, const BValue& value);
	void slotMenuAppendTrigger(BObject* object, const BValue& value);

protected:
	void freshHeads();
	bool checkHeadFile(BListItem* item);
	bool openHtmlFile(const BString& htmlFileName);
	void signTitleChanged(BWidget* widget, bool changed);
	void freshHeadItemIcons(BListItem* item);

protected:
	virtual void updateEvent(const BEvent& event);

	virtual void styleEvent(const BEvent& event);

private:
	BButton*				_openButton;
	BButton*				_saveButton;
	BButton*				_saveAllButton;
	BLineEdit*					_headPathEdit;
	BLineEdit*					_htmlPathEdit;
	BButton*				_readOnlyButton;
	BMenuBar*				_menuBar;
	BButton*				_removeButton;

	BListWidget*			_headListWidget;
	BTabWidget*				_tabWidget;
	PropertyBox*			_propertyBox;

	BFileDialog*			_fileDialog;
	CheckDialog*			_checkDialog;
	BMenu*					_listMenu;
	BMenu*					_pageMenu;
	BMenu*					_tableMenu;
	BMenu*					_tabMenu;

	BHtmlWidget*			_htmlWidget;

	BFolder					_includeFolder;
	BFolder					_documentFolder;

	BImageHolder			_normalImage;
	BImageHolder			_dirtyImage;
	BImageHolder			_emptyImage;

	BIconHolder				_htmlIcon;
	BIconHolder				_textIcon;
	BIconHolder				_treeIcon;
};

#endif